#ifndef __INTEGER_H__
  #define __INTEGER_H__

#include <string>
#include <iostream>
#include <climits>

using namespace std;

//! An implementation for large integers

/*!
This class helps to work with unlimited long numbers (integers).

Implementation date: 2006

Usage:

\code
integer i1;
i1 = "1234567890123456789012345678901234567890";

integer i2;
i2 = "99999999999999999999999999999999999999999999999";

integer i3 = i1 * i2;
\endcode
*/

class integer {
friend ostream &operator<<(ostream &os, const integer &i1);

private:
  string s;    // holds the number
  string rest; // holds the rest, see operator/

public:
  //! returns the string representation of the object
  const string &to_string() const;

  //! sets the value of this object to the given string, which must be a number (may throw an exception)
  void set(const string &s1);

  //! returns the rest part
  const string &get_rest() const;

  //! returns the length of this integer
  size_t len() const;

  //! assignment operator
  integer &operator=(const integer &i1);

  //! assignment operator (may throw an exception)
  integer &operator=(const string &s1);

  //! assignment operator
  integer &operator=(int i);

  //! comparison operator
  bool operator==(const integer &i1) const;

  //! comparison operator
  bool operator==(const string &s1) const;

  //! less than operator
  bool operator<(const integer &i1) const;

  //! less than or equal operator
  bool operator<=(const integer &i1) const;

  //! less than operator
  bool operator<(const string &s) const;

  //! greater than operator
  bool operator>(const integer &i1) const;

  //! greater than or equal operator
  bool operator>=(const integer &i1) const;

  //! greater than operator
  bool operator>(const string &s) const;

  //! plus operator
  integer operator+(const integer &i1) const;

  //! minus operator
  integer operator-(const integer &i1) const;

  //! multiplication operator
  integer operator*(const integer &i1) const;

  //! division operator (may throw an exception)
  integer operator/(const integer &i1) const;

  //! modulus operator (may throw an exception)
  integer operator%(const integer &i1) const;

  //! power operator (may throw an exception)
  integer operator^(const integer &i1) const;

  //! returns the abs of this integer
  integer get_abs() const;

  //! copy constructor
  integer(const integer &i1);

  //! default constructor
  integer();

  //! constructor
  integer(const string &s);

  //! destructor
  virtual ~integer();
}; // class integer

#endif
